﻿/****** Object:  Role [Medianamik_DataAccess]    Script Date: 12/04/2008 11:39:31 ******/
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'Medianamik_DataAccess')
BEGIN
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'Medianamik_DataAccess' AND type = 'R')
CREATE ROLE [Medianamik_DataAccess]

END

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[aspnet_AnyDataInTables]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[aspnet_AnyDataInTables] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[aspnet_Applications_CreateApplication]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[aspnet_Applications_CreateApplication] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[aspnet_CheckSchemaVersion]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[aspnet_CheckSchemaVersion] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[aspnet_RegisterSchemaVersion]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[aspnet_RegisterSchemaVersion] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[aspnet_Setup_RemoveAllRoleMembers]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[aspnet_Setup_RemoveAllRoleMembers] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[aspnet_Setup_RestorePermissions]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[aspnet_Setup_RestorePermissions] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AspNet_SqlCachePollingStoredProcedure]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[AspNet_SqlCachePollingStoredProcedure] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AspNet_SqlCacheQueryRegisteredTablesStoredProcedure]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[AspNet_SqlCacheQueryRegisteredTablesStoredProcedure] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AspNet_SqlCacheRegisterTableStoredProcedure]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[AspNet_SqlCacheRegisterTableStoredProcedure] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AspNet_SqlCacheUnRegisterTableStoredProcedure]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[AspNet_SqlCacheUnRegisterTableStoredProcedure] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AspNet_SqlCacheUpdateChangeIdStoredProcedure]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[AspNet_SqlCacheUpdateChangeIdStoredProcedure] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[aspnet_UnRegisterSchemaVersion]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[aspnet_UnRegisterSchemaVersion] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[aspnet_Users_CreateUser]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[aspnet_Users_CreateUser] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[aspnet_Users_DeleteUser]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[aspnet_Users_DeleteUser] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[aspnet_WebEvent_LogEvent]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[aspnet_WebEvent_LogEvent] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetNodeTypeByNodeId]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[GetNodeTypeByNodeId] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_ApplyNodePermissionToChildren]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_ApplyNodePermissionToChildren] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_ApplyTypePermissionToChildren]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_ApplyTypePermissionToChildren] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_CleanUpNodePropertyValues]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_CleanUpNodePropertyValues] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_GetChildNodeIds]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_GetChildNodeIds] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_GetChildNodeIdsFilteredByType]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_GetChildNodeIdsFilteredByType] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_GetChildNodes]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_GetChildNodes] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_GetChildNodesFilteredByType]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_GetChildNodesFilteredByType] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_GetCurrentParentTypes]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_GetCurrentParentTypes] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_GetCurrentPath]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_GetCurrentPath] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_GetNodeIdsByParam]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_GetNodeIdsByParam] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_GetNodeIdsByType]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_GetNodeIdsByType] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_GetNodeRevisions]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_GetNodeRevisions] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_GetNodesByType]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_GetNodesByType] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_GetParentNodeTypes]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_GetParentNodeTypes] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_GetPrimaryLookupItems]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_GetPrimaryLookupItems] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_GetPropertiesForChildsRecursive]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_GetPropertiesForChildsRecursive] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_GetPropertiesRecursive]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_GetPropertiesRecursive] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_GetRootNodesByType]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_GetRootNodesByType] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_GetSomeChildNodeIds]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_GetSomeChildNodeIds] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_GetSomeChildNodeIdsFilteredByType]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_GetSomeChildNodeIdsFilteredByType] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_GetSomeChildNodes]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_GetSomeChildNodes] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_GetSomeChildNodesFilteredByType]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_GetSomeChildNodesFilteredByType] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_LoadChildNodes]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_LoadChildNodes] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_LoadParentNodes]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_LoadParentNodes] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_PropertyValueIsUnique]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_PropertyValueIsUnique] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_TypeHasNodes]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_TypeHasNodes] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_TypeNodesCount]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[medianamik_TypeNodesCount] TO [Medianamik_DataAccess] AS [dbo]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[spGrantExectoAllStoredProcs]') AND type in (N'P', N'PC'))
GRANT EXECUTE ON [dbo].[spGrantExectoAllStoredProcs] TO [Medianamik_DataAccess] AS [dbo]